<template>
  <div id="app">
    <keep-alive exclude="Detail">
      <router-view v-if="isRouterAlive"></router-view>
    </keep-alive>
    <main-tab-bar></main-tab-bar>
  </div>
</template>

<script>
import MainTabBar from "components/content/mainTabbar/MainTabBar.vue";
export default {
  name: "App",
  data() {
    return {
      isRouterAlive: true
    };
  },
  created() {
    this.$router.afterEach((to, from) => {
      if (to.path == "/detail") {
        this.reload();
      }
    });
  },
  methods: {
    // 通过v-if原理重新渲染router-view
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function() {
        this.isRouterAlive = true;
      });
    }
  },
  components: {
    MainTabBar
  }
};
</script>

<style>
@import "assets/css/base.css";
</style>
